-
-
Notifications
You must be signed in to change notification settings - Fork 9
fix: Restore relay selection after backup import #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix relay selection not working after backup restore by ensuring relay information is properly exported and imported. Changes: - Add isMyRelay field to ContactExport (nullable for backward compatibility) - Export isMyRelay field in MigrationExporter.exportContactsForIdentity() - Restore isMyRelay field during import in MigrationImporter.importContacts() - Restore manualPropagationNode setting when relay contact is imported - Disable auto-select when manual relay is restored - Trigger auto-selection after import if enabled but no relay was restored - Inject PropagationNodeManager into MigrationImporter for auto-selection This ensures that after restoring from backup: 1. The relay contact is properly marked with isMyRelay=true 2. The manual propagation node preference is restored 3. Auto-selection is triggered if enabled but no relay was restored Fixes the issue where no propagation node would be selected after backup restore, requiring manual re-configuration.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile OverviewGreptile SummaryThis PR fixes relay (propagation node) selection restoration after backup import by:
The implementation correctly addresses the ordering issues from previous review comments. The new Backward compatibility: Old backups without Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant MigrationImporter
participant Database
participant SettingsRepository
participant PropagationNodeManager
User->>MigrationImporter: importData(backup.columba)
Note over MigrationImporter: Phase 1: Database Transaction
MigrationImporter->>MigrationImporter: importDatabaseData()
MigrationImporter->>MigrationImporter: importContacts()
loop For each contact
alt contact.isMyRelay == true
Note over MigrationImporter: Track relay hash<br/>(don't write to DataStore yet)
MigrationImporter->>MigrationImporter: restoredRelayHash = contact.destinationHash
end
MigrationImporter->>Database: Insert ContactEntity with isMyRelay flag
end
Note over MigrationImporter: Phase 2: Settings Import
MigrationImporter->>SettingsRepository: importSettings(bundle.settings)
SettingsRepository->>SettingsRepository: importAllPreferences()
Note over SettingsRepository: Restores all DataStore prefs<br/>including manualPropagationNode<br/>and autoSelectPropagationNode<br/>(if present in backup)
Note over MigrationImporter: Phase 3: Relay Restoration
MigrationImporter->>MigrationImporter: restoreRelaySettings(restoredRelayHash)
MigrationImporter->>SettingsRepository: getManualPropagationNode()
SettingsRepository-->>MigrationImporter: manualRelay
alt manualRelay != null
Note over MigrationImporter: Settings already restored relay<br/>from backup DataStore
else restoredRelayHash != null
Note over MigrationImporter: Fallback: use contact's isMyRelay<br/>(for old backup format)
MigrationImporter->>SettingsRepository: saveManualPropagationNode(restoredRelayHash)
MigrationImporter->>SettingsRepository: saveAutoSelectPropagationNode(false)
else No relay from either source
MigrationImporter->>SettingsRepository: getAutoSelectPropagationNode()
SettingsRepository-->>MigrationImporter: isAutoSelect
alt isAutoSelect == true
Note over MigrationImporter: Trigger auto-selection<br/>to pick a relay
MigrationImporter->>PropagationNodeManager: enableAutoSelect()
end
end
MigrationImporter-->>User: Import complete
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
app/src/main/java/com/lxmf/messenger/migration/MigrationImporter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/lxmf/messenger/migration/MigrationImporter.kt
Outdated
Show resolved
Hide resolved
- Extract restoreRelaySettings() to run after both the DB transaction and importSettings(), ensuring DataStore writes are never inside a Room transaction scope (prevents inconsistent state on rollback) - Return relay hash through ContactImportResult → TransactionResult instead of writing to DataStore inside importContacts() - Check if importSettings already restored the relay before writing from the contact's isMyRelay flag, removing redundant overwrites - Add warning log when multiple relay contacts found in backup Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Problem
After a fresh install + backup restore, no propagation node is selected. The user must manually go into Settings and pick a relay, even if they had one selected before the backup.
Root Cause
ContactExportdoesn't include theisMyRelayfield. During export, the relay designation is silently dropped. On import, all contacts are created withisMyRelay = false, and themanualPropagationNodeDataStore preference isn't restored either. Auto-selection may not trigger because the import flow doesn't explicitly kick it off.Fix
Export side:
isMyRelay: Boolean?toContactExport(nullable for backward compatibility with older backups)isMyRelayinMigrationExporter.exportContactsForIdentity()Import side:
isMyRelayduringimportContacts()manualPropagationNodepreferenceautoSelectPropagationNode = falsewhen restoring a manual relaypropagationNodeManager.enableAutoSelect()PropagationNodeManagerintoMigrationImportervia HiltBackward compatibility: Old backups without
isMyRelaywill have it default tonull(treated asfalse), falling through to auto-selection — same behavior as before this fix.Testing
isMyRelay: trueappears in export JSON